package com.sinosoft.zyxt.jdbc;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;

public class GlobalConfigReader {
  
  private static Logger logger = Logger.getLogger(GlobalConfigReader.class);

  static final String CONFIG = "global.Oracleconfig.properties";
  static Properties prop = null;

  static{
    prop = new Properties();
  }

  public static String getStringValue(String key){
    try {  
      InputStream in = GlobalConfigReader.class.getClassLoader().getResourceAsStream(CONFIG);
      if(in!=null)
        prop.load(in);
    } catch(IOException e) {  
      logger.error("error message = {}" + e.getMessage(), e);
    }  
    if(prop == null)
      return null;
    else
      return prop.getProperty(key);
  }

  public static boolean getBooleanValue(String key) {
    String value = getStringValue(key);
    return StringUtils.equals("true", value) ? true : false;
  }
}
